<#if roles.canManageBid && roles.canCreateBid>
<div class="col-md-12">
	<div class="panel panel-primary">
		<div class="panel-heading">
			<h3 class="panel-title">
				<i class="icon-paste icon-large"></i>
				进行中的投标
			</h3>
		</div>
		<#if toBid??>
		<table class="table table-hover">
			<tr>
				<th class="text-center" width="190">项目编号</th>
				<th class="text-center">项目名称</th>
				<th class="text-center" width="160">投标状态</th>
				<th class="text-center" width="190">招标编号</th>
				<th class="text-center" width="160">招标方式</th>
			</tr>
			<#list toBid as b>
			<tr onclick="window.open('${request.contextPath}/bid/view/${b.id}','_blank');" style="cursor: pointer;">
				<td class="text-center">${b.projectNo}</td>
				<td class="text-center">${b.name}</td>
				<td class="text-center">${b.status.value}</td>
				<td class="text-center">${b.bidNo}</td>
				<td class="text-center">${b.bidWay}</td>
			</tr>
			</#list>
		</table>
		<#else>
		<div class="panel-body text-danger">暂无数据！</div>
		</#if>
	</div>
</div>

<div class="col-md-12">
	<div class="panel panel-primary">
		<div class="panel-heading">
			<h3 class="panel-title">
				<i class="icon-pencil icon-large"></i>
				待补录“中标服务费”
			</h3>
		</div>
		<#if noServerMoneyBid??>
		<table class="table table-hover no-server-money-bid">
			<tr>
				<th class="text-center" width="55"></th>
				<th class="text-center" width="190">项目编号</th>
				<th class="text-center">项目名称</th>
				<th class="text-center" width="160">投标状态</th>
				<th class="text-center" width="190">招标编号</th>
				<th class="text-center" width="160">招标方式</th>
			</tr>
			<#list noServerMoneyBid as b>
			<tr data-bid="${b.id}" style="cursor: pointer;">
				<td>
					<div class="btn btn-success btn-xs add-bid-server-money">补录</div>
				</td>
				<td class="text-center item no">${b.projectNo}</td>
				<td class="text-center item name">${b.name}</td>
				<td class="text-center item">${b.status.value}</td>
				<td class="text-center item">${b.bidNo}</td>
				<td class="text-center item">${b.bidWay}</td>
			</tr>
			</#list>
		</table>
		<#else>
		<div class="panel-body text-danger">暂无数据！</div>
		</#if>
	</div>

	<script type="text/javascript">
		var html = function(name, no, bidId) {
			return '<div class="row">\
			<div class="col-md-12 text-center">\
				<h3>'
					+ name
					+ '</h3>\
				<small>'
					+ no
					+ '</small>\
				<hr>\
			</div>\
			<form class="form-add-bid-money-server">\
				<div class="col-md-6">\
							<div class="form-group">\
						<div class="input-group">\
							<div class="input-group-addon">\
								<div class="form-item-title">\
									<span class="not-null-star">*</span>\
									中标服务费\
								</div>\
							</div>\
							<input type="hidden" name="bid.id" value="' + bidId + '">\
							<input type="hidden" name="payOut" value="true">\
							<input type="hidden" name="inAccount" value="true">\
							<input type="hidden" name="name" value="中标服务费">\
							<input type="hidden" name="invoice" value="true">\
							<input type="text" class="form-control not-empty number" name="total" placeholder="填写金额">\
							<div class="input-group-addon">元</div>\
						</div>\
					</div>\
				</div>\
				<div class="col-md-6">\
					<div class="form-group">\
						<div class="input-group">\
							<div class="input-group-addon">\
								<div class="form-item-title">\
									<span class="not-null-star">*</span>\
									缴纳时间\
								</div>\
							</div>\
							<input type="text" class="form-control not-empty datetimepicker" name="time" data-foot="false" data-format="yyyy-MM-dd" value="" placeholder="请选择日期" readonly="readonly">\
						</div>\
					</div>\
				</div>\
			</form>\
		</div>';
		};

		require([ 'suredyModal', '${request.contextPath}/app/js/form-checker.js', 'suredyDatetimepicker', 'jqueryForm' ], function(Modal, formChecker) {
			$('table.no-server-money-bid td.item').on('click', function() {
				var tr = $(this).parent();
				var id = tr.data('bid');
				window.open('${request.contextPath}/bid/view/' + id, '_blank');
			});

			// 补录中标服务费
			$('div.btn.add-bid-server-money').on('click', function() {
				var $this = $(this);
				var tr = $this.parents('tr');
				var bid = tr.data('bid');
				var no = tr.find('td.item.no').text();
				var name = tr.find('td.item.name').text();

				Modal.showModal({
					title : '补录中标服务费',
					icon : 'icon-pencil',
					size : 'lg',
					text : html(name, no, bid),
					okClick : function() {
						var form = $('form.form-add-bid-money-server');

						if (!formChecker(form)) {
							return false;
						}

						form.ajaxSubmit({
							url : '${request.contextPath}/bid-money/add-bid-server-money',
							type : 'post',
							dataType : 'json',
							success : function(result, textStatus, jqXHR) {
								if (!result || !result.success) {
									var msg = (result && result.msg) || '操作失败！';
									alert(msg);
									return false;
								}

								Suredy.loadContent('${request.contextPath}/front-page');
								Modal.closeModal();
							},
							error : function(jqXHR, textStatus, errorThrown) {
								alert('操作失败！\n\n' + errorThrown);
							}
						});
					}
				});
			});
		});
	</script>
</div>
</#if>
